package hello;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VisitorController {


	@RequestMapping(value = "/visitors", method = RequestMethod.GET)
	public List<MobileVisitor> readAllVisitors() {
		System.out.println("### Querying all Visitors.");
		MobileVistorDB dbaccess = new MobileVistorDB();
		return dbaccess.readAllVisitors();
	}
	
	@RequestMapping(value = "/visitors", method = RequestMethod.POST)
	@ResponseStatus(HttpStatus.CREATED)
	public String createVisitor(@RequestBody MobileVisitor visitor) {
		System.out.println("### Creating Visitor.  applicantName :" + visitor);
		MobileVistorDB dbaccess = new MobileVistorDB();
//		MobileVisitor visitor = new MobileVisitor(0L, applicantName, spouseName, "Address_" + RandomStringUtils.randomAlphanumeric(20), "PassportNo_"
//						+ RandomStringUtils.randomAlphanumeric(10), "VoterID_" + RandomStringUtils.randomAlphanumeric(8),
//						"RationCardNo_" + RandomStringUtils.randomAlphanumeric(7), "ProfileImage_" + RandomStringUtils.randomAlphanumeric(50), "ProfileImage2_"
//										+ RandomStringUtils.randomAlphanumeric(50));
		dbaccess.createtVisitor(visitor);
		return "success";
	}
	
	

}
